<?php
namespace app\index\controller;


use think\Controller;
use think\Request;
use think\Db;
class Index
{
    public function index()
    {
       // select id ,count(sid) from oa_article group by sid;

       // select id ,title ,count(sid) from oa_article group by sid;
// Db::field("s.id, s.username, s.name,group_concat(r.name) rname")

      // $data = Db::field('group_concat(title),sid')
      //           ->name('article')
      //           ->group('sid')
      //           ->select();
      $data = Db::name('article')
                ->group('sid')
                ->select();
                // dump(Db::getlastSql());die;
                // dump($data);die;
      $a = [];           
      foreach ($data as $k => $v) {
             $b=date('Y-m-d',$v['time']);
             $c = array_push($v,$b);
             $d = Db::name('sort')
                   ->field('sort')
                   ->where('id',$v['sid'])
                   ->find();
            $e = array_push($v,$d['sort']);
             $a[] = $v;
        }

         // var_dump($a);die;
        return view('',[
             'data'=>$a
            ]);
//        return view();
    }

   


}









